package export.monster
{
	import base.BaseMonster;
	
	import com.game.manager.AnimationManager;
	
	import export.bullet.EnemyMoveBullet;
	
	import export.bullet.RegionBullet;
	
	import flash.geom.Rectangle;
	
	
	public class Monster304 extends BaseMonster
	{
		public function Monster304()
		{
			super();
		}
		
		override protected function initBBDC():void
		{
			bbdc = AnimationManager.getAnimation("Monster304Action");
			bbdc.setAction("idle");
			bbdc.turnRight();
			bbdc.addCallBack(onEnterFrame, onActionOver);
			bodyContainer.addChild(bbdc);
		}
		
		override protected function initCollideArea():void
		{
			collideBox = new Rectangle(-25,-82,50,82);
			super.initCollideArea();
		}
		
		override protected function initAttribute():void
		{
			super.initAttribute();
			mavo.attackRange = 150;
		}
		
		override public function getActionHurt(action:String):int
		{
			switch (action)
			{
				case "attack1":
					return super.getActionHurt(action);
				case "skill1":
					return super.getActionHurt(action) * 2;
				case "skill2":
					return super.getActionHurt(action) * 2;
			}
			return 0;
		}
		
		override protected function onEnterFrame(action:String, frameCount:int):void
		{
			switch (action)
			{
				case "attack1":
					if(frameCount == 7)
					{
						var b:RegionBullet = new RegionBullet();
						b.setOwner(this);
						b.setHurt(getActionHurt("attack1"));
						b.setDirect(bbdc.getDirect());
						b.setCollideArea(20,-60,120 * bbdc.getDirect(),65);
						b.setAction("Monster304Attack1");
						b.setDestroyInCount(bbdc.frameLeft);
						gc.gameScene.addChild(b);
						magicBulletArray.push(b);
					}
					break;
				case "skill1":
					if(frameCount == 4)
					{
						var b:RegionBullet = new RegionBullet();
						b.setOwner(this);
						b.setHurt(getActionHurt("skill1"));
						b.setDirect(bbdc.getDirect());
						b.setCollideArea(13,-105,140 * bbdc.getDirect(),110);
						b.setAction("Monster304Attack1");
						b.setDestroyInCount(8);
						gc.gameScene.addChild(b);
						magicBulletArray.push(b);
					}
					if(frameCount == 13)
					{
						var b:RegionBullet = new RegionBullet();
						b.setOwner(this);
						b.setHurt(getActionHurt("skill1"));
						b.setDirect(bbdc.getDirect());
						b.setCollideArea(50,-105,300 * bbdc.getDirect(),110);
						b.setAction("Monster304Attack1");
						b.setDestroyInCount(11);
						gc.gameScene.addChild(b);
						magicBulletArray.push(b);
					}
					break;
				case "skill2":
					if(frameCount == 6)
					{
						for (var i:int = 0; i < 5; i++)
						{
							var bu:EnemyMoveBullet = new EnemyMoveBullet("Monster304Bullet1");
							bu.setOwner(this);
							bu.setHurt(getActionHurt("skill2"));
							bu.setAction("Monster304Skill1");
							bu.setDirect(bbdc.getDirect());
							bu.setDistance(1000);
							bu.setSpeed(0,15);
							bu.setSpeedAdd(0,1);
							bu.setPosition(getCollideCenter().x + 100 * i * bbdc.getDirect(), getCollideCenter().y - 500);
							gc.gameScene.addChild(bu);
							magicBulletArray.push(bu);
						}
					}
			}
		}
		
		override protected function beforeSkill1Start():Boolean
		{
			return this.hasTarget() && AUtils.GetDisBetweenTwoObj(this, this.curAttackTarget) < 300;
		}
		
		override protected function beforeSkill2Start():Boolean
		{
			return this.hasTarget() && AUtils.GetDisBetweenTwoObj(this,this.curAttackTarget) < 500;
		}
	}
}